<template>
    <table border="1">
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="pwd">
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
                <input type="button" value="登录" @click="login" class="btn btn-success">
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import { onMounted } from 'vue';
import axios from 'axios'
const name=ref('');
const pwd=ref('');
const login=()=>{
    if(name.value==""){
        alert('用户名不能为空');
        return;
    }
    if(pwd.value==""){
        alert('密码不能为空');
        return;
    }
    axios.get('http://localhost:5021/api/Dept/Login',{
        params:{
            name:name.value,
            pwd:pwd.value
        }
    })
    .then(res=>{
        if(res.data.locode==-1){
            alert(res.data.lomessage);
        }
        else if(res.data.locode==-2){
            alert(res.data.lomessage);
        }
        else if(res.data.locode==1){
            alert(res.data.lomessage);
        }
    })
    .catch(error=>{
        console.log(error);
    })
}
</script>